/*
 * XMPPConnection.h
 *
 *  Created on: Apr 1, 2011
 *      Author: trietto
 */

#ifndef XMPPCONNECTION_H_
#define XMPPCONNECTION_H_

#include <FNet.h>
#include "xmpp/packet/Packet.h"

class XMPPConnection : public Osp::Base::Object,
	public Osp::Net::Sockets::ISocketEventListener{
public:
	XMPPConnection();
	virtual ~XMPPConnection();
public:
	result CreateSocket(void);
	void CloseSocket(void);
	result SendData(Packet *packet);
	result SendInitStream(void);
	result SendCloseStream(void);
	void ReceiveData(void);

	// ISocketEventListener
	void OnSocketConnected(Osp::Net::Sockets::Socket& socket);
	void OnSocketClosed(Osp::Net::Sockets::Socket& socket, Osp::Net::Sockets::NetSocketClosedReason reason);
	void OnSocketReadyToReceive(Osp::Net::Sockets::Socket& socket);
	void OnSocketReadyToSend(Osp::Net::Sockets::Socket& socket);
    bool IsConnected();

    void OnSocketAccept(Osp::Net::Sockets::Socket& socket) {}

private:
	Osp::Net::Sockets::Socket*	__pSocket;
	bool __bConnected;
};

#endif /* XMPPCONNECTION_H_ */
